package com.vcc.service.boss.response.trans;

import com.vcc.data.entity.Transaction;
import com.vcc.service.boss.response.baseVo.BossBaseVo;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import org.apache.commons.lang3.StringUtils;

import java.io.Serializable;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Date;

@EqualsAndHashCode(callSuper = true)
@Data
@Setter
@Getter
public class TransactionVoBoss extends BossBaseVo implements Serializable {
    private String tranId;
    private String originalTranId;
    private String settleTranId;
    private String channelTranId;
    private String originalChannelTranId;
    private String channelSettleTranId;
    private String channel;
    private String channelCardId;
    private String cardNumber;
    private Long userCardId;
    private Long userId;
    private String account;
    private String sectionNo;
    private String merchantName;
    private String merchantCountry;
    private Date tranDate;
    private BigDecimal billingAmount;
    private String billingCurrency;
    private BigDecimal merchantAmount;
    private String merchantCurrency;
    private BigDecimal settleAmount;
    private String settleCurrency;
    private BigDecimal fee;
    private String feeCurrency;
    private Date settleDate;
    private Date postDate;
    private String transactionType;
    private String remark;
    private String status;
    private String mcc;
    private String cardType;
    private String dealerAccount;

    public TransactionVoBoss() {
    }

    public TransactionVoBoss(Transaction authTran) {
        super.setId(authTran.getId());
        this.tranId = authTran.getTranId();
        this.originalTranId = authTran.getOriginalTranId();
        this.settleTranId = authTran.getSettleTranId();
        this.channelTranId = authTran.getChannelTranId();
        this.originalChannelTranId = authTran.getOriginalChannelTranId();
        this.channelSettleTranId = authTran.getChannelSettleTranId();
        this.channel = authTran.getChannel();
        this.channelCardId = authTran.getChannelCardId();
        this.cardNumber = authTran.getCardNumber();
        this.userCardId = authTran.getUserCardId();
        this.userId = authTran.getUserId();
        this.account = authTran.getAccount();
        this.merchantName = authTran.getMerchantName();
        this.merchantCountry = authTran.getMerchantCountry() == null ? "" : authTran.getMerchantCountry();
        this.tranDate = authTran.getTranDate();
        this.billingAmount = authTran.getBillingAmount() == null ? BigDecimal.ZERO : authTran.getBillingAmount().setScale(2, RoundingMode.HALF_UP);
        this.billingCurrency = authTran.getBillingCurrency();
        this.merchantAmount = authTran.getMerchantAmount() == null ? BigDecimal.ZERO : authTran.getMerchantAmount().setScale(2, RoundingMode.HALF_UP);
        this.merchantCurrency = authTran.getMerchantCurrency();
        this.settleAmount = authTran.getSettleAmount() == null ? BigDecimal.ZERO : authTran.getSettleAmount().setScale(2, RoundingMode.HALF_UP);
        this.settleCurrency = authTran.getSettleCurrency();
        this.fee = authTran.getFee() == null ? BigDecimal.ZERO : authTran.getFee().setScale(2, RoundingMode.HALF_UP);
        this.feeCurrency = authTran.getFeeCurrency();
        this.settleDate = authTran.getSettleDate();
        this.postDate = authTran.getPostDate();
        this.transactionType = authTran.getTransactionType();
        this.remark = StringUtils.isEmpty(authTran.getRemark()) ? "" : authTran.getRemark();
        this.status = authTran.getStatus();
        this.mcc = StringUtils.isEmpty(authTran.getMcc()) ? "" : authTran.getMcc();
        this.cardType = authTran.getCardType() == null ? "" : authTran.getCardType();
        this.dealerAccount = StringUtils.isEmpty(authTran.getDealerAccount()) ? "" : authTran.getDealerAccount();
    }
}
